package com.teame.readbaby.po;

import java.util.ArrayList;
import java.util.List;


public class Cart {
	//封装每个item项
	private List<Product> productList = new ArrayList<Product>();
	private String cartNum;
	private String cartJifen;
	private String cartPrice;
	private String youhui;
	
	public List<Product> getProductList() {
		return productList;
	}
	public void setProductList(List<Product> productList) {
		this.productList = productList;
	}
	/**
	 * 获取购物车的所有商品加起来的总数
	 * @return
	 */
	public String getCartNum() {
		cartNum ="";
		int num =0;
		for (Product item : productList) {
			num += Integer.parseInt(item.getNumber());
		}
		return cartNum = String.valueOf(num);
	}
	public void setCartNum(String cartNum) {
		this.cartNum = cartNum;
	}
	/**
	 * 获取商品的总积分
	 * @return
	 */
	public String getCartJifen() {
		cartJifen="";
		float price=0;
		for (Product item : productList) {
			price+= Float.parseFloat(item.getTotalPrice());
		}
		return cartJifen=String.valueOf(price);
	}
	public void setCartJifen(String cartJifen) {
		this.cartJifen = cartJifen;
	}
	/**
	 * 获取购物车所有商品的加起来的所有价格
	 * @return
	 */
	public String getCartPrice() {
		cartPrice="";
		float price=0;
		for (Product item : productList) {
			price+= Float.parseFloat(item.getTotalPrice());
		}
		return cartPrice=String.valueOf(price);
	}
	public void setCartPrice(String cartPrice) {
		this.cartPrice = cartPrice;
	}
	public String getYouhui() {
		return youhui;
	}
	public void setYouhui(String youhui) {
		this.youhui = youhui;
	}

	
}
